// JavaScript Document
//显示当周的订单的记录情况，运用拆线图和条形图切换展示数据
$(document).ready(function() {


	regional_analysis();
	
	operation();

});

function operation() {
	$("#analysis_btn").on("click", function() {
		$("#regional_analysis_echart").empty();
//		$("#top_img").css("visibility", "visible");
				$.ajax({
					url : getRootPath() + "/analysis/regional_analysis",
					type : "GET",
					dataType : "json",
					data : "pro="+$("#province").val()+"&area="+$("#city").val(),
					success : function(result) {
						if (result.code == 100) {
//							$("#top_img").css("visibility", "hidden");
							regional_analysis02(result);
						}
					}
				});
	});
}


//积分服务类型分析图
function regional_analysis02(re){
	var myChart = echarts.init(document.getElementById('regional_analysis_echart'));

// 指定图表的配置项和数据
var option = {
    title : {
		show: true,
        text: '商品销售类型占比',
        top:20,
        x:'left'

		
    },
    tooltip : {
        trigger: 'item',
        formatter: "{a} <br/>{b} : {c} ({d}%)"
    },
    legend: {
        orient: 'vertical',
        left: 500,
		top :50,
        data: ['食品','家电','手机数码','女装','男装','鞋靴','箱包','内衣配饰','百货','家居家纺']
    },
    series : [
        {
            name: '商品类型',
            type: 'pie',
            radius : '65%',
            center: ['25%', '55%'],
            data:[
          	 	 {value:re.extend.map.sptype, name:'食品'},
           		 {value:re.extend.map.jdtype, name:'家电'},
                {value:re.extend.map.sjtype, name:'手机数码'},
                {value:re.extend.map.nzWtype, name:'女装'},
                {value:re.extend.map.nzMtype, name:'男装'},
           		 {value:re.extend.map.xxtype, name:'鞋靴'},
                {value:re.extend.map.xbtype, name:'箱包'},
                {value:re.extend.map.nytype, name:'内衣配饰'},
                {value:re.extend.map.bhtype, name:'百货'},
                {value:re.extend.map.jjtype, name:'家居家纺'}
         
                
            ]
        }
    ]
};

// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
}




//积分服务类型分析图
function regional_analysis(){
//	$("#top_img").css("visibility", "hidden");
	var myChart = echarts.init(document.getElementById('regional_analysis_echart'));

// 指定图表的配置项和数据
var option = {
    title : {
		show: true,
        text: '商品销售类型占比',
        top:20,
        x:'left'

		
    },
    tooltip : {
        trigger: 'item',
        formatter: "{a} <br/>{b} : {c} ({d}%)"
    },
    legend: {
        orient: 'vertical',
        left: 500,
		top :50,
        data: ['食品','家电','手机数码','女装','男装','鞋靴','箱包','内衣配饰','百货','家居家纺']
    },
    series : [
        {
            name: '商品类型',
            type: 'pie',
            radius : '65%',
            center: ['25%', '55%'],
            data:[
          	 	 {value:34, name:'食品'},
           		 {value:24, name:'家电'},
                {value:35, name:'手机数码'},
                {value:30, name:'女装'},
                {value:24, name:'男装'},
           		 {value:34, name:'鞋靴'},
                {value:35, name:'箱包'},
                {value:10, name:'内衣配饰'},
                {value:34, name:'百货'},
                {value:35, name:'家居家纺'}
         
                
            ]
        }
    ]
};

// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
}

// 获得根目录
function getRootPath() {
	var strFullPath = window.document.location.href;
	var strPath = window.document.location.pathname;
	var pos = strFullPath.indexOf(strPath);
	var prePath = strFullPath.substring(0, pos);
	var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
	return (prePath + postPath);
}


